Sqlite Note

Meow King October 30, 2023 Updated: October 30, 2023 #sqlite #sql #note
  1. return the rows being inserted, deleted, or updated.
    See RETURNING
    Example Usage:

    CREATE TABLE t0(
    a INTEGER PRIMARY KEY,
    b DATE DEFAULT CURRENT_TIMESTAMP,
    c INTEGER
    );
    INSERT INTO t0(c) VALUES (random()), (random()) RETURNING *;
    
  2. use PRAGMA foreign_keys = ON; to enable foreign key check.

  3. specific types like CHAR(30), CHAR(50) are eventually converted into sqlite built-in types like TEXT. So there is no length check for string.
    Datatypes In SQLite #3.1.1. Affinity Name Examples

  4. Primary Key uauslly not the true primary key, and the rowid is.
    exception: Integer Primary Key becomes an alias for the rowid in Rowid Tables.
    If there is not integer primary key alias as rowid, then rowid is not persistent. To See rowid:

    select rowid, * from table; -- or `oid`, `_rowid_`
    

    See Rowid Tables